// 睡眠锁头文件

#ifndef __SLEEPLOCK_H__
#define __SLEEPLOCK_H__

#include "types.h"
#include "spinlock.h"

struct sleeplock {
  uint locked;       // 锁是否被持有？
  struct spinlock lk; // 保护此睡眠锁的自旋锁
  
  // 用于调试
  char *name;        // 锁的名称
  int pid;           // 持有锁的进程
};

void initsleeplock(struct sleeplock *lk, char *name);
void acquiresleep(struct sleeplock *lk);
void releasesleep(struct sleeplock *lk);
int holdingsleep(struct sleeplock *lk);

#endif // __SLEEPLOCK_H__